# (MSYS2) Maintainer: Ray Donnelly <mingw.android@gmail.com>
# (ArchLinux) Maintainer: Christian Hesse <mail@eworm.de>
# (ArchLinux) Contributor: Alexey Vasiliev <robbinton@gmail.com>

_realname=freerdp-git
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgdesc="Free RDP client (mingw-w64)"
pkgver=r8949.43a5680
pkgrel=1
depends=("${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-ffmpeg")
makedepends=("git"
             "${MINGW_PACKAGE_PREFIX}-cmake")
arch=('any')
url="http://www.freerdp.com/"
license=('Apache License 2.0')
provides=("${MINGW_PACKAGE_PREFIX}-freerdp")
source=("${_realname}::git+https://github.com/FreeRDP/FreeRDP.git")

sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}"/${_realname}
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}"/${_realname}
}

build() {
  [[ -d ${CARCH}-build ]] && rm -rf ${CARCH}-build
  mkdir ${CARCH}-build
  cd ${CARCH}-build
  MSYS2_ARG_CONV_EXCL=-DCMAKE_INSTALL_PREFIX \
  ${MINGW_PREFIX}/bin/cmake \
      -G'MSYS Makefiles' \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DCMAKE_WINDOWS_VERSION="WINXP" \
      -DWITH_PULSE=OFF \
      -DWITH_SERVER=ON \
      -DMSVC_RUNTIME="dynamic" \
      ../${_realname}

  make VERBOSE=1
}

package() {
  cd ${CARCH}-build
  make DESTDIR="${pkgdir}" install
}
